<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="../base/base.jspf" %>
<div class="layui-form" style="padding: 47px 0 0 70px;">
    <div class="layui-col-xs12">
        <input type="hidden" name="id" value="${unit.id}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">单位编号</label>
            <div class="layui-input-inline">
                <input type="text" value="${unit.unitNo}" name="unitNo" autocomplete="off"
                       placeholder="请输入单位编号" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单位名称</label>
            <div class="layui-input-inline">
                <input type="text" value="${unit.unitName}" autocomplete="off"
                       lay-verify="required"
                       name="unitName" placeholder="请输入单位名称" class="layui-input"/>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit id="unit-front-submit" lay-filter="unit-front-submit" value="确认"/>
    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: "${ctx}/static/framework/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use(["index", "form"], function () {
        var form = layui.form;

        form.on("submit(unit-front-submit)", function (data) {
            $("#unit-front-submit").attr("disabled",true);
            tip_index = load();
            var field = data.field;
            $.ajax({
                url: "${ctx}/unit/unitSubmit",
                type: "post",
                dataType: "json",
                data: field,
                success: function (data) {
                    layer.close(tip_index);
                    if (data.result) {
                        parentTableReload("unit-page-data");
                        successUp(data.info);
                        closeDialog();
                    } else {
                        $("#unit-front-submit").attr("disabled",false);
                        error(data.info);
                    }
                }
            });
        });
    });
</script>